﻿using Newtonsoft.Json.Linq;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using X.Core.Models;

namespace X.Core.Interfaces
{
    public interface IDevice : ITreeNodeModel
    {
        (int, string) Refresh(JObject param = null);
        (int, string) Open(JObject param = null);
        (int, string) Close(JObject param = null);
        (int, string) TestConnection(JObject param = null);
        (int, string) GetInfo(out JObject info, JObject param = null);
        (int, string) ExecuteCommand(string command, JObject param = null);
        (int, string, JObject result) ExecuteCommandA(string command, JObject param);
        (int, string, JArray result) ExecuteCommandB(string command, JObject param);

        Task<(int, string)> OpenAsync(JObject param = null);
        Task<(int, string)> CloseAsync(JObject param = null);
        Task<(int, string)> ExecuteCommandAsync(string command, JObject param = null);
        Task<(int, string, JObject result)> ExecuteCommandAAsync(string command, JObject param);
        Task<(int, string, JArray result)> ExecuteCommandBAsync(string command, JObject param);


        int RefreshPeriod { get; set; }
        bool IsOpen { get; set; }
        bool IsOffline { get; set; }
        bool IsDebugModel { get; set; }
        bool IsBusy { get; set; }
        bool IsError { get; set; }
        bool IsStopped { get; set; }
        bool IsOpening { get; set; }
        bool IsClosing { get; set; }
        bool IsClosed { get; set; }
        bool IsNeedClose { get; set; }
        bool IsResetting { get; set; }
        int RefreshCount { get; set; }
        int RetryPeriod { get; set; }
        int RetryCount { get; set; }
        IParameterModel Parameter { get; set; }
        ObservableCollection<IDevice> Devices { get; set; }
        ObservableCollection<BitDataModel> XDatas { get; set; }
        ObservableCollection<BitDataModel> YDatas { get; set; }
        ObservableCollection<UshortDataModel> OutputDatas { get; set; }
        ObservableCollection<UshortDataModel> InputDatas { get; set; }
        ObservableCollection<UshortDataModel> ConfigDatas { get; set; }
        ObservableCollection<ListModel<double>> DDatas { get; set; }
        IDevice ParentDevice { get; set; }
        IDevice RootDevice { get; set; }
        ILogger Logger { get; set; }
    }
}
